import React, { useEffect } from "react";
import { RouterProvider, useLocation, useNavigate } from "react-router-dom";
import { router } from "./router";
function App() {
  return (
    <div className="App">
      <RouterProvider router={router}></RouterProvider> 
    </div>
  );
}



const withLogin = (Comp) => {
  return () => {
    const token = localStorage.getItem('token');
    const navigate = useNavigate()
    const location = useLocation()
    useEffect(() => {
      if(!token && location.pathname !== '/login') {
        navigate('/login')
      }
    }, [location])

    return <Comp></Comp>
  }
}

export default (App);

